// 可选链
const user = {
  address: {
    street: 'xx街道',
    getNum(){
      return '80号'
    }
  }
}

// es5
// const street = user && user.address && user.address.street
// const num = user && user.address && user.address.getNum()

// console.log('ES5 语法')
// console.log(street)
// console.log(num)

const street = user?.address?.street
const num = user?.address?.getNum()
console.log('ES6 语法')
console.log(street)
console.log(num)